package com.lagou;

import com.lagou.bean.ComsumerComponet;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;

public class AnnotationConsumerMain {

    public static void main(String[] args) throws IOException, InterruptedException {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        applicationContext.start();
        ComsumerComponet service = applicationContext.getBean(ComsumerComponet.class);
        while (true) {
            /*for (int i = 0; i < 1000; i++) {
                Thread.sleep(5);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        String name = service.sayHello("张三");
                        System.out.println("result:" + name);
                    }
                }).start();
            }*/
            System.in.read();
            String name = service.sayHello("张三");
            System.out.println("result:" + name);
        }
    }

    @Configuration
    @EnableDubbo
    @PropertySource("classpath:/dubbo-consumer.properties")
    @ComponentScan(value = "com.lagou.bean")
    static class ConsumerConfiguration {

    }
}
